package enumandlambda;

/**
 * @author shkstart
 * 实现Runnale接口新建线程
 * @create 2022-11-28-13:25
 */
public class ThreadDemo4 {
    public static void main(String[] args) {
//       创建Runnable
        MyThread2 myThread2 = new MyThread2();
//        创建一个线程
        Thread thread = new Thread(myThread2);
//        启动线程
        thread.start();
    }
}
class MyThread2 implements Runnable{

    @Override
    public void run() {
        //具体实现业务的代码
        Thread thread = Thread.currentThread();//获取当前的线程
        System.out.println(thread.getName());
    }
}
